<?php
class App_View_Helper_CountryListing{

	public function countryListing($operation,$id,$seriesId = "",$type = "points",$tournamentid){
		
		echo $tournamentid;

		$criteria = new Criteria();
		/*$criteria->add(TournamentPeer::ID, $seriesId)
					->add(TournamentPeer::IS_ACTIVE, 'Y');

		$tournamentTeams = Team


*/       $c = new Criteria();
         $c->addJoin(TournamentToTeamPeer::TEAM_ID, TeamPeer::ID, Criteria::INNER_JOIN);
         $c->add(TournamentToTeamPeer::TOURNAMENT_ID, $tournamentid);
		 $oTeams = TeamPeer::doSelect($c);
		$html = "";
		foreach($oTeams as $team){
			
		 $imgcriteria = new Criteria();        
         $imgcriteria ->add(MediaPeer::OWNER_ID,$team->getId(),Criteria::EQUAL);
         $imgcriteria ->add(MediaPeer::TYPE,'team',Criteria::EQUAL);
		 $oMedia = MediaPeer::doSelectOne( $imgcriteria );
		 $imagepath=Zend_Registry::get("baseUrl").'files/team1/'.$oMedia->getFileName();
		 ?>
		 
		 <?php 
			$html .='<li style="background-image:url('.$imagepath.'); background-repeat:no-repeat; width:67px;
"><a href="javascript:void(0)" onclick="ShowPlayers('. $team->getId() .',\''. $operation .'\')"><div id="team-small-block">'. $team->getCode() .'</div></a></li>';

		}

		if($html != ""){

			$html = '<script type="text/javascript" src="'.Zend_Registry::get("baseUrl").'js/team.js"></script>
					<ul class="country-select inline">'. $html ."</ul>";
		}
		return $html;
	}

}